export interface IGoods {
  name: string;
  pice: number;
  [propName: string]: any;
}

interface ISearch {
  showHistorySearch: boolean;
  showHotSearch: boolean;
  searchLists: Array<IGoods>;
  setSearchLists: (list: Array<IGoods>) => void;
}

class Search implements ISearch {
  showHistorySearch = false;
  showHotSearch = false;
  searchLists: Array<IGoods> = [];
  static instance = null;
  static getInstance() {
    if (!Search.instance) {
      (Search as any).instance = new Search();
      return Search.instance;
    } else {
      return Search.instance;
    }
  }

  setHotSearchStatus(status: boolean) {
    this.showHotSearch = status;
  }

  setHistorySearchStatus(status: boolean) {
    this.showHistorySearch = status;
  }

  getHistorySearchStatus() {
    return this.showHistorySearch;
  }

  getHotSearchStatus() {
    return this.showHotSearch;
  }

  getSearchLists() {
    return this.searchLists;
  }

  setSearchLists(list: Array<IGoods>): void {
    this.searchLists = list;
  }
}

export default Search.getInstance();
